package com.ruoyi.common.utils;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang.math.RandomUtils;

import weixin.popular.bean.paymch.Transfers;
import weixin.popular.util.XMLConverUtil;

public class OrderUtil {

	public static String genOrderNo() {

		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		String newDate = sdf.format(new Date());
		String result = "";
		for (int i = 0; i < 12; i++) {
			result += RandomUtils.nextInt(10);
		}
		return newDate + "0" + result;

	}

	public static String WX_PAY_APP_ID = "wxc82b8a2796d988f8";

	public static String WX_PAY_MCHID = "1534312541";

	public static String WX_PAY_MCH_KEY = "58fbb3abc8ca2e6a1649b80293a26a77";

	public static void main(String[] args) {

		Transfers transfers = new Transfers();

		transfers.setAmount(100);
		transfers.setOpenid("test");
		transfers.setMch_appid(WX_PAY_APP_ID);
		transfers.setMchid(WX_PAY_MCHID);
		transfers.setCheck_name("NO_CHECK");
		transfers.setDesc("记背单词提现到帐");
		// transfers.setDevice_info("");
		transfers.setNonce_str("wxc82b8a2796d988f8");
		transfers.setPartner_trade_no("1234");
		// transfers.setSign_type("HMAC-SHA256");
		transfers.setSpbill_create_ip("127.0.0.1");
		BigDecimal yuan = BigDecimal.valueOf(100).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP);
		transfers.setYuan_amount(yuan);

		String xml = XMLConverUtil.convertToXML(transfers);
		System.out.println(xml);
	}
}
